two_level_self_organizing_map Derived Type

type, public, extends(kohonen_map_base) :: two_level_self_organizing_map

Class to represent a two level self_organized_map


Inherits

type~~two_level_self_organizing_map~~InheritsGraph type~two_level_self_organizing_map two_level_self_organizing_map type~distance_base distance_base type~two_level_self_organizing_map->type~distance_base distance_function type~factory_distance factory_distance type~two_level_self_organizing_map->type~factory_distance factory type~kohonen_layer_parameters kohonen_layer_parameters type~two_level_self_organizing_map->type~kohonen_layer_parameters parameters type~kohonen_map_base kohonen_map_base type~two_level_self_organizing_map->type~kohonen_map_base type~kohonen_prototype kohonen_prototype type~two_level_self_organizing_map->type~kohonen_prototype grid, cluster_layer type~rkiss05_generator rkiss05_generator type~two_level_self_organizing_map->type~rkiss05_generator rnumber_grator type~random_generator_base random_generator_base type~rkiss05_generator->type~random_generator_base

Type-Bound Procedures

procedure, public :: create => create_2lsom

  • public subroutine create_2lsom(kohonen_map, training_parameters)

    Constructor of a two_level self_organized_map class

    Arguments

    Type IntentOptional Attributes Name
    class(two_level_self_organizing_map) :: kohonen_map

    A two_level_self_organizing_map object

    type(kohonen_layer_parameters), dimension(:) :: training_parameters

    A kohonen_layer_parameters structure

procedure, public :: destroy => destroy_2lsom

  • public subroutine destroy_2lsom(kohonen_map)

    Destructor of a two_level self_organized_map

    Arguments

    Type IntentOptional Attributes Name
    class(two_level_self_organizing_map) :: kohonen_map

    A two_level_self_organizing_map object

procedure, public :: train => train_2lsom

  • public subroutine train_2lsom(kohonen_map, input_data)

    Subroutine to train a two_level self_organized_map

    Arguments

    Type IntentOptional Attributes Name
    class(two_level_self_organizing_map) :: kohonen_map

    A two_level_self_organizing_map object

    type(kohonen_pattern), intent(inout), dimension(:) :: input_data

    A kohonen_pattern array

procedure, public :: predict => predict_2lsom

  • public subroutine predict_2lsom(kohonen_map, input_data, map_output)

    Subroutine to make a prediction from a trained two_level self_organized_map

    Arguments

    Type IntentOptional Attributes Name
    class(two_level_self_organizing_map) :: kohonen_map

    A two_level_self_organizing_map object

    type(kohonen_pattern), intent(inout), dimension(:) :: input_data

    A kohonen_pattern array

    integer, intent(out), dimension(:,:) :: map_output

    An integer array

procedure, public :: train_grid_layer

  • public subroutine train_grid_layer(kohonen_map, input_data)

    Subroutine to train the grid layer of a two_level self_organized_map

    Arguments

    Type IntentOptional Attributes Name
    class(two_level_self_organizing_map) :: kohonen_map

    A two_level_self_organizing_map object

    type(kohonen_pattern), intent(inout), dimension(:) :: input_data

    A kohonen_pattern array

procedure, public :: train_cluster_layer

  • public subroutine train_cluster_layer(kohonen_map)

    Subroutine to train the cluster layer of a two_level self_organized_map

    Arguments

    Type IntentOptional Attributes Name
    class(two_level_self_organizing_map) :: kohonen_map

    A two_level_self_organizing_map object

procedure, public :: print => print_2lsom

  • public subroutine print_2lsom(kohonen_map, unit_)

    Subroutine to print the layers of a two_level self_organized_map

    Arguments

    Type IntentOptional Attributes Name
    class(two_level_self_organizing_map) :: kohonen_map

    A two_level_self_organizing_map object

    integer, optional :: unit_

    An integer variable with the unit

procedure, public :: query => query_2lsom

  • public subroutine query_2lsom(kohonen_map, input_pattern, sample_index)

    Function to find the input samples associated with specific vector

    Arguments

    Type IntentOptional Attributes Name
    class(two_level_self_organizing_map) :: kohonen_map

    A two_level_self_organizing_map object

    real(kind=wp), intent(inout), dimension(:,:) :: input_pattern

    A real array

    integer, allocatable :: sample_index(:)

    An integer array

procedure, public :: set_cluster_layer

  • public subroutine set_cluster_layer(kohonen_map, seed)

    Subroutine to initialize the cluster layer of a Two Level Self-Organizing Map

    Arguments

    Type IntentOptional Attributes Name
    class(two_level_self_organizing_map) :: kohonen_map

    A two_level_self_organizing_map object

    integer :: seed

    An integer variable with the random seed

procedure, public :: set_parameters

procedure, public :: read_som_layer

  • public subroutine read_som_layer(kohonen_map, som_fl, layer_type)

    Subroutine to read the prototypes of the first/seconf layer of a two level self_organized_map

    Arguments

    Type IntentOptional Attributes Name
    class(two_level_self_organizing_map) :: kohonen_map

    A two_level_self_organizing_map object

    character(len=*) :: som_fl

    A character variable

    character(len=*) :: layer_type

    A character variable

procedure, public :: calculate_sum2_clusters_samples => evaluate_2lsom

  • public subroutine evaluate_2lsom(kohonen_map, input_data, results)

    Subroutine to calculate some clustering statistics of a two-level self_organized_map

    Arguments

    Type IntentOptional Attributes Name
    class(two_level_self_organizing_map) :: kohonen_map

    A two_level_self_organizing_map object

    type(kohonen_pattern), intent(inout), dimension(:) :: input_data

    A kohonen_pattern array

    real(kind=wp), optional, dimension(:) :: results

    A real array

procedure, public :: get_cluster_samples

  • public subroutine get_cluster_samples(kohonen_map, clusters)

    Accessor to cluster results obtained using a two-level self_organized_map

    Arguments

    Type IntentOptional Attributes Name
    class(two_level_self_organizing_map) :: kohonen_map

    A two_level_self_organizing_map object

    integer, intent(inout), dimension(:) :: clusters

    An integer array

procedure, public :: calculate_sum2_clusters_grid

  • public subroutine calculate_sum2_clusters_grid(kohonen_map, results)

    Subroutine to calculate some clustering statistics of a two-level self_organized_map

    Arguments

    Type IntentOptional Attributes Name
    class(two_level_self_organizing_map) :: kohonen_map

    A two_level_self_organizing_map object

    real(kind=wp), optional, dimension(:) :: results

    A real array

procedure, public, nopass :: external_train_map


  • public subroutine external_train_map(x, nvar, npat, som_type, nx1, ny1, nepoch1, alpha1, grid_type1, distance_type1, neigh_type1, toroidal1, nx2, nepoch2, alpha2, grid_type2, prot, distortion, u_matrix, coords, number_patterns, node_index) bind(C, name="train_2lsom")

    Subroutine to connect the two_level_self_organizing_map module to R o C Use iso_c_binding module

    Arguments

    Type IntentOptional Attributes Name
    real(kind=c_double), intent(in) :: x(npat,nvar)

    Real variables

    integer(kind=c_int), intent(in) :: nvar

    Integere variables

    integer(kind=c_int), intent(in) :: npat

    Integere variables

    integer(kind=c_int), intent(in) :: som_type

    Integere variables

    integer(kind=c_int), intent(in) :: nx1

    Integere variables

    integer(kind=c_int), intent(in) :: ny1

    Integere variables

    integer(kind=c_int), intent(in) :: nepoch1

    Integere variables

    real(kind=c_double), intent(in) :: alpha1

    Real variables

    integer(kind=c_int), intent(in) :: grid_type1

    Integer variables

    integer(kind=c_int), intent(in) :: distance_type1

    Integer variables

    integer(kind=c_int), intent(in) :: neigh_type1

    Integer variables

    integer(kind=c_int), intent(in) :: toroidal1

    Integere variables

    integer(kind=c_int), intent(in) :: nx2

    Integer variables

    integer(kind=c_int), intent(in) :: nepoch2

    Integer variables

    real(kind=c_double), intent(in) :: alpha2

    Real variables

    integer(kind=c_int), intent(in) :: grid_type2

    Integer variables

    real(kind=c_double), intent(out) :: prot(nx1*ny1,nvar)

    Real variables

    real(kind=c_double), intent(out) :: distortion(nepoch1)

    Real variables

    real(kind=c_double), intent(out) :: u_matrix(2*nx1-1,2*ny1-1)

    Real variables

    real(kind=c_double), intent(out) :: coords(nx1*ny1,3)

    Real variables

    integer(kind=c_int), intent(out) :: number_patterns(nx1,ny1)

    Integer variables

    integer(kind=c_int), intent(out) :: node_index(npat,3)

    Integer variables

Source Code

   type,extends(kohonen_map_base) :: two_level_self_organizing_map
   private
!!   Class to represent a two level self_organized_map
   type(kohonen_prototype),allocatable :: grid(:,:,:),cluster_layer(:)
      real(kind=wp),allocatable :: coordinates(:,:)
      integer,allocatable :: number_patterns(:,:,:),cells_index(:,:)
      integer,allocatable :: cluster_number_patterns(:),cluster_cells_index(:,:)
      integer,allocatable :: grid_cluster(:,:,:),cluster_samples(:)
      real(kind=wp),allocatable :: u_matrix(:,:,:),distance(:,:),cells_distances(:,:)
      integer,allocatable :: number_cluster_samples(:),index_cluster_samples(:,:)
      type(kohonen_layer_parameters),dimension(2) :: parameters
      type(factory_distance) :: factory
      class(distance_base),allocatable :: distance_function
      type(rkiss05_generator),dimension(2) :: rnumber_grator
      integer :: seed1,seed2
      integer :: number_variables,number_variables1,number_variables2,number_clusters
      integer :: number_nodes
   contains
      procedure,public :: create => create_2lsom
      procedure,public :: destroy => destroy_2lsom
      procedure,private :: create_random_sample
      procedure,public :: train => train_2lsom
      procedure,public :: predict => predict_2lsom
      procedure,public :: train_grid_layer
      procedure,public :: train_cluster_layer
      procedure,public :: print => print_2lsom
      procedure,public :: query => query_2lsom
      procedure,public :: set_cluster_layer
      procedure,public :: set_parameters
   !    procedure,public :: read => read_som
      procedure,private :: query_2lsom
      procedure,public :: read_som_layer
      procedure,private :: calculate_u_matrix
      procedure,private :: find_best_match_unit
      procedure,private :: update_weights
      procedure,private :: calculate_distance_between_prototypes
      procedure,private :: assign_input_to_clusters
      !procedure,public :: get_count => get_count_2lsom
      !procedure,public :: get_index => get_index_som
      !procedure,public :: get_u_matrix => get_u_matrix_som
      procedure,public :: calculate_sum2_clusters_samples => evaluate_2lsom
      procedure,public :: get_cluster_samples
      procedure,public :: calculate_sum2_clusters_grid
      procedure,nopass,private :: calculate_distance_matrix
      procedure,nopass,private :: calculate_coordinates
   !    
      procedure,nopass,public :: external_train_map
   !    procedure,nopass,public :: external_predict_map    
   !*****   
   end type two_level_self_organizing_map